perm filename QUAL[LSP,JRA] blob sn#189831 filedate 1975-12-04 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	Here are two sets of BNF equations:
C00005 ENDMK
C⊗;
Here are two sets of BNF equations:

	the infix expressions

<exp> ::= <exp>+<term> | <term>
<term> ::= <term>*<factor> | <factor>
<factor> ::= <identifier> | <number>

the second set:
	the postfix expressions

<post> ::= <post><post>+ | <post><post>* | <identifier> | <number>

 where the class <identifier> is the usual class of lower-case identifiers;
i.e. alpha-numeric strings subject to the constraint that the first character
must be alphabetic. The class <number> is restricted to  the digit strings 
throughout this discussion.

1. Give  data-structure representations for the infix and postfix expressions
generated by each  set of BNF equations.

2. Write an algorithm to translated from infix to postfix representation.

3. Write an algorithm to evaluate infix expressions. That is, the algorithm
will take your representation of an infix expression and will act as
an evaluator. Don't forget that variables may appear; thus you should
include a symbol table mechanism.

4. Write an algorithm to compile postfix expressions for the following machine:

The machine has one AC register, named AC. It has conventional storage and
the following instructions:

LAC loc		loc is the symbolic name for a memory location. This instruction
		is to  put a copy of the contents of loc in AC. 
			c(AC)← c(loc)

DAC loc		loc is as above. DAC copies the contents of AC into loc.
			c(loc)← c(AC)

ADD loc		contents of loc are added to contents of AC with the 
		result replacing the contents of AC.
			c(AC) ← c(AC)+c(loc)

MPY loc			c(AC) ← c(AC)*c(loc)



Hints: If you don't finish parts, at least show what you were thinking
	about. If you show that you understood how to do the problem you
	will get partial credit.

       Give a reasonable amount of thought to the representation. Care
	here will pay dividends later!